﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using SqlCon;
using CrystalDecisions.CrystalReports.Engine; 
using System.Drawing.Printing;



namespace yfxt
{
    public partial class ms_fycfdy : Form
    {
        public ms_fycfdy()
        {
            InitializeComponent();
        }

        ms_mzfy mzdy;

        SqlConnection  conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction);
        private void ms_fycfdy_Load(object sender, EventArgs e)
        {
            mzdy=(ms_mzfy)this.Owner;

           string s_01="select brxm,(case cflx when '1'then '自费' when '3' then '医保'end ) as cflx ,"+
                        "kfrq,fphm,ygxm from ms_cf01,gy_ygdm where  ms_cf01.ysdm=gy_ygdm.ygdm and "+
                        " cfhm=" + mzdy.s_ymcz.ToString() +
                        " group by brxm,cflx ,kfrq,fphm,ygxm";

            string s_02="select ypmc,ms_cf02.yfgg as ypgg,ypdw,ypdj,cdmc as ypcd,ms_cf02.ypsl as ypsl "+
                         " from  ms_cf01,ms_cf02,gy_ygdm,yk_typk,yk_ypcd,yk_cddz  "+
                         " where ms_cf01.cfsb=ms_cf02.cfsb and ms_cf01.ysdm=gy_ygdm.ygdm "+
                         " and ms_cf02.ypxh=yk_typk.ypxh and yk_typk.ypxh=yk_ypcd.ypxh "+
                         " and yk_ypcd.ypcd=yk_cddz.ypcd and cfhm="+mzdy.s_ymcz.ToString() +
                         " group by ypmc,ms_cf02.yfgg,ypdw,ypdj,cdmc,ms_cf02.ypsl ";




            ds_fycf_dy fydy = new ds_fycf_dy(); //建立dataset数据集

            SqlDataAdapter da_01 = new SqlDataAdapter(s_01, conn);//建立适配器

            SqlDataAdapter da_02 = new SqlDataAdapter(s_02,conn);

            da_01.Fill(fydy.Tables["cf01_cf02_ygdm_01"]);//将搜出来的数据填充到表cf01_cf02_ygdm_01、02表中

            da_02.Fill(fydy.Tables["cf01_cf02_ygdm_02"]);

            Cry_fycfdy cr = new Cry_fycfdy(); //建立报表类

            cr.SetDataSource(fydy);//将报表的数据源设置成dataset

            crystalReportViewer1.ReportSource = cr;//将报表空间的报表数据源设置成上面建立的报表



 





        }
    }
}
